package com.cgbl.cg.adapter

import androidx.appcompat.widget.AppCompatImageView
import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.model.CollectDetailBean
import com.robot.base.utils.pic.ImageLoaderUtils

class CollectPopAdapter : BaseQuickAdapter<CollectDetailBean, BaseViewHolder>(R.layout.app_item_collect_pop) {
    var oldCheckView: AppCompatImageView? = null
    var selectPosition = -1
    override fun convert(holder: BaseViewHolder, item: CollectDetailBean) {
        holder.setText(R.id.item_tv_name, item.collectName)
            .setText(R.id.item_tv_content, "内容数量 ${item.worksCount?:"0"}")
        ImageLoaderUtils.displayRound(context, holder.getView(R.id.item_iv_img), item.collectImages, 4)
        val ivCheck = holder.getView<AppCompatImageView>(R.id.item_iv_check)
        ivCheck.setOnClickListener {
            if (oldCheckView != null) {
                oldCheckView?.isSelected = !oldCheckView!!.isSelected
            }
            ivCheck.isSelected = !ivCheck.isSelected
            selectPosition = holder.adapterPosition
            oldCheckView = ivCheck
        }
    }
}